﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace imarks.Utility.Log
{
    public class LogMessage
    {
        public string UserName { get; set; }
        public string ObjectID { get; set; }
        public LogObjectType ObjectType { get; set; }
        public int LogCode { get; set; }
        public string Message { get; set; }
        public string Exception { get; set; }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message">日志信息</param>
        public LogMessage(string message)
        {
            this.Message = message;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="message">日志信息</param>
        /// <param name="e">异常信息</param>
        public LogMessage(string message, Exception e)
        {
            this.Message = message;
            this.Exception = e.Message;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userName">操作用户</param>
        /// <param name="objectID">操作对象</param>
        /// <param name="objectType">对象类型</param>
        /// <param name="logCode">日志类型</param>
        public LogMessage(string userName, string objectID, LogObjectType objectType, LogCode logCode)
        {
            this.UserName = userName;
            this.ObjectID = objectID;
            this.ObjectType = objectType;
            this.LogCode = logCode.GetHashCode();
            this.Message = logCode.ToString();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userName">操作用户</param>
        /// <param name="objectID">操作对象</param>
        /// <param name="objectType">对象类型</param>
        /// <param name="logCode">日志类型</param>
        /// <param name="message">日志信息</param>
        public LogMessage(string userName, string objectID, LogObjectType objectType, LogCode logCode, string message)
        {
            this.UserName = userName;
            this.ObjectID = objectID;
            this.ObjectType = objectType;
            this.LogCode = logCode.GetHashCode();
            this.Message = message;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="userName">操作用户</param>
        /// <param name="objectID">操作对象</param>
        /// <param name="objectType">对象类型</param>
        /// <param name="logCode">日志类型</param>
        /// <param name="message">日志信息</param>
        /// <param name="e">异常信息</param>
        public LogMessage(string userName, string objectID, LogObjectType objectType, LogCode logCode, string message, Exception e)
        {
            this.UserName = userName;
            this.ObjectID = objectID;
            this.ObjectType = objectType;
            this.LogCode = logCode.GetHashCode();
            this.Message = message;
            this.Exception = e.Message;
        }
    }
}
